package com.idanchuang.support.etcache.local;

import com.idanchuang.support.etcache.pressure.PressureChecker;

import java.util.concurrent.TimeUnit;

/**
 *
 * LocalCache配置类
 *
 * @author yjy
 * Created at 2021/12/22 1:10 下午
 */
public class LocalCacheConfig {

    /** 默认缓存容量 */
    public static final long DEFAULT_MAXIMUM_SIZE = 200;
    /** 默认过期时间 */
    public static final long DEFAULT_EXPIRE = 600000;
    /** 默认时间单位 */
    public static final TimeUnit DEFAULT_TIME_UNIT = TimeUnit.MILLISECONDS;

    /**
     * 缓存名称
     */
    protected String cacheName;
    /**
     * 缓存容量
     */
    protected long maximumSize = DEFAULT_MAXIMUM_SIZE;
    /**
     * 过期时间
     */
    protected long expire = DEFAULT_EXPIRE;
    /**
     * 时间单位
     */
    protected TimeUnit timeUnit = DEFAULT_TIME_UNIT;
    /**
     * 压测断言者
     */
    protected final PressureChecker pressureChecker;

    public LocalCacheConfig(String cacheName, PressureChecker pressureChecker) {
        this.cacheName = cacheName;
        this.pressureChecker = pressureChecker;
    }

    public long getMaximumSize() {
        return maximumSize;
    }

    public String getCacheName() {
        return cacheName;
    }

    public void setCacheName(String cacheName) {
        this.cacheName = cacheName;
    }

    public void setMaximumSize(long maximumSize) {
        this.maximumSize = maximumSize;
    }

    public TimeUnit getTimeUnit() {
        return timeUnit;
    }

    public void setTimeUnit(TimeUnit timeUnit) {
        this.timeUnit = timeUnit;
    }

    public long getExpire() {
        return expire;
    }

    public void setExpire(long expire) {
        this.expire = expire;
    }

    public PressureChecker getPressureChecker() {
        return pressureChecker;
    }
}
